//
//  YZCardVC.m
//  VET
//
//  Created by 刘文靖 on 2018/6/29.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "YZCardVC.h"
#import "YZUser.h"
#import "YZStatementHeader.h"
#import "UIImageView+CornerRadius.h"
#import <UIImageView+WebCache.h>
@interface YZCardVC ()
@property (weak, nonatomic) IBOutlet UIView *contentView;
@property (weak, nonatomic) IBOutlet UILabel *nickNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *organizationLabel;
@property (weak, nonatomic) IBOutlet UILabel *mobileLabel;
@property (weak, nonatomic) IBOutlet UIImageView *avatarImageView;
@end

@implementation YZCardVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的名片";
    [self.avatarImageView zy_cornerRadiusAdvance:28 rectCornerType:UIRectCornerAllCorners];
    [self refreshWithLoginUser];
}

- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    [self setupGradientLayer];
}
- (void)setupGradientLayer{
    CAGradientLayer *maskLayer = [CAGradientLayer layer];
    CGColorRef topGradientColor = yzColorGS.CGColor;
    CGColorRef bottomGradientColor = yzColorGE.CGColor;;
    maskLayer.colors = @[(__bridge id)topGradientColor, (__bridge id)bottomGradientColor];
    maskLayer.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);
    [_contentView.layer insertSublayer:maskLayer atIndex:0];
}

- (void)refreshWithLoginUser{
    YZUser *loginUser  = [YZUser sharedInstance];
    self.nickNameLabel.text = loginUser.nickName;
    self.organizationLabel.text = loginUser.company?:@"";
    self.mobileLabel.text = loginUser.phone;
    [self.avatarImageView sd_setImageWithURL:[NSURL URLWithString:loginUser.avatarOriginal] placeholderImage:[UIImage imageNamed:@"icon_im"]];
}

@end
